home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / lamstex / inputs / cardord.tex < prev    next >
Text File  |  1991-09-06  |  2KB  |  67 lines

  1. \catcode`\@=11
  2. \def\cardnine@#1{\ifcase#1\or one\or two\or three\or four\or five\or
  3.  six\or seven\or eight\or nine\fi}
  4. \def\cardinal#1{\count@#1\relax
  5.  \ifnum\count@>99 \number\count@
  6.  \else
  7.   \ifnum\count@=\z@ zero%
  8.   \else
  9.    \ifnum\count@<\ten@\cardnine@\count@
  10.    \else
  11.     \ifnum\count@<20
  12.      \advance\count@-\ten@
  13.      \ifcase\count@ ten\or eleven\or twelve\or thirteen\or fourteen\or
  14.       fifteen\or sixteen\or seventeen\or eighteen\or nineteen\fi
  15.     \else
  16.      \count@@\count@\count@@@\count@@
  17.      \divide\count@\ten@\multiply\count@\ten@
  18.      \advance\count@@@-\count@\divide\count@\ten@
  19.      \ifcase\count@\or\or twenty\or thirty\or forty\or fifty\or sixty\or
  20.       seventy\or eighty\or ninety\fi
  21.      \ifnum\count@@@=\z@\else-\cardnine@\count@@@\fi
  22.     \fi
  23.    \fi
  24.   \fi
  25.  \fi}
  26. \def\ordnine@#1{\ifcase#1\or first\or second\or third\or fourth\or fifth\or
  27.  sixth\or seventh\or eighth\or ninth\fi}
  28. \def\ordsuffix@{\count@@@@\count@
  29.  \divide\count@\ten@
  30.  \count@@@\count@\count@@\count@
  31.  \divide\count@@\ten@\multiply\count@@\ten@
  32.  \advance\count@@@-\count@@
  33.  \ifnum\count@@@=\@ne th%
  34.  \else
  35.   \count@@@\count@@@@
  36.   \count@@\count@@@@
  37.   \divide\count@@\ten@\multiply\count@@\ten@
  38.   \advance\count@@@-\count@@
  39.   \ifcase\count@@@ th\or st\or nd\or rd\else th\fi
  40.  \fi}
  41. \def\nordinal#1{\count@#1\relax\number\count@\ordsuffix@}
  42. \def\spordinal#1{\count@#1\relax\number\count@$^{\text{\ordsuffix@}}$}
  43. \def\ordinal#1{\count@#1\relax
  44.  \ifnum\count@>99 \number\count@\ordsuffix@
  45.  \else
  46.    \ifnum\count@=\z@ zeroth%
  47.   \else
  48.     \ifnum\count@<\ten@\ordnine@\count@
  49.     \else
  50.      \ifnum\count@<20 \advance\count@-\ten@
  51.       \ifcase\count@ tenth\or eleventh\or twelfth\or thirteenth\or
  52.        fourteenth\or fifteenth\or sixteenth\or seventeenth\or eighteenth\or
  53.        nineteenth\fi
  54.      \else
  55.       \count@@\count@
  56.       \divide\count@\ten@\multiply\count@\ten@
  57.       \count@@@\count@@\advance\count@@@-\count@
  58.       \divide\count@\ten@
  59.       \ifcase\count@\or\or twent\or thirt\or fort\or fift\or sixt\or sevent\or
  60.        eight\or ninet\fi
  61.       \ifnum\count@@@=\z@ ieth\else y-\ordnine@\count@@@\fi
  62.      \fi
  63.     \fi
  64.   \fi
  65.  \fi}
  66. \catcode`\@=\active
  67.